#region <!--##session BUZDataSetWholeClass##-->
/*<!--##
codeGeneratorVariable_DisplayCode.Append(GeneralUsing() + Environment.NewLine);
##-->*/
using System.Runtime.Serialization;
using System.Xml; 
namespace <!--##=RepositoryManager.Instance.Repository.ProjectName##-->
{
	[Serializable()]
	public class BODataSet : BODataSetParent
	{
		/*<!--##
		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetInnerClasses() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetMembers() + Environment.NewLine);
		 codeGeneratorVariable_DisplayCode.Append(BUZDataSetStaticMetods() + Environment.NewLine);
		##-->*/
	}
}
	
<!--##/session##-->
#endregion

#region <!--##session BUZDataSetStaticMetods##-->
		#region Static Methods
		private static void CreateDataSet(DataSet ds)
		{
		DataTable dtParent,dtChild;
		//****** Adding Tables to DataSet 
				/*<!--##
				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];
					<%@EntityIncludes%>
				##-->*/
		ds.Tables.Add(new <!--##=className##-->DataTable());
				/*<!--##
				}
				##-->*/
					


		//****** Adding Relations to DataSet 
		DataColumn[] parentColumns,childColumns;		
				/*<!--##
				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];
					<%@EntityIncludes%>
					foreach(string relKey in  entity.Children.Keys)
					{   
						Entity.Relation relation = entity.Children[relKey];
						<%@RelationIncludes%>
						Entity refEntity = relation.ReferencedEntity;
						<%@RefEntityIncludes%>
				##-->*/
		//**[<!--##=childRelationName##-->]
		parentColumns=new DataColumn[<!--##=refKey.Length##-->];
		childColumns =new DataColumn[<!--##=refKey.Length##-->];;

		dtParent=ds.Tables["<!--##=entityName##-->"];
		dtChild=ds.Tables["<!--##=refEntityName##-->"];
				/*<!--##
						for(int i=0; i<refKey.Length; i++)
						{   
				##-->*/
		parentColumns[<!--##=i##-->] = dtParent.Columns["<!--##=nativeKey[i].Name##-->"];
		childColumns[<!--##=i##-->] = dtChild.Columns["<!--##=refKey[i].Name##-->"];
				/*<!--##
						}
				##-->*/
				
		ds.Relations.Add("<!--##=childRelationName##-->",parentColumns,childColumns);
					
					
				/*<!--##
					}  
				}
				##-->*/
					
			
		}
		#endregion
<!--##/session##-->
#endregion

#region <!--##session BUZDataSetInnerClasses##--> 
		#region Inner Classes
		public class TableNames
		{
			/*<!--##
			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];
				<%@EntityIncludes%>
			##-->*/
			public const string <!--##=className##--> = "<!--##=entityName##-->";
			/*<!--##
			}
			##-->*/
		}
		public class RelationNames
		{
			/*<!--##
			foreach(string key in RepositoryManager.Instance.Entities.Keys)
			{ 
				Entity entity = RepositoryManager.Instance.Entities[key];
				foreach(string relKey in  entity.Parents.Keys)
				{   
					Entity.Relation relation = entity.Parents[relKey];
					<%@RelationIncludes%>
			##-->*/
			public const string <!--##=parentRelationProperty##--> = "<!--##=parentRelationName##-->";
			/*<!--##
				} 
			}
			##-->*/
		}	
		#endregion 
<!--##/session##-->
#endregion

#region <!--##session BUZDataSetMembers##--> 
        #region Members.
		//**Constructors
		public BODataSet():base("BODataSet"){CreateDataSet(this);}
		protected BODataSet(SerializationInfo info, StreamingContext context)
		{
			string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
			if ((strSchema != null))
			{
				DataSet ds = new DataSet();
				ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
				/*<!--##
				foreach(string key in RepositoryManager.Instance.Entities.Keys)
				{ 
					Entity entity = RepositoryManager.Instance.Entities[key];
					<%@EntityIncludes%>
				##-->*/
				if ((ds.Tables["<!--##=entityName##-->"] != null))
				{
					this.Tables.Add(new <!--##=className##-->DataTable(ds.Tables["<!--##=entityName##-->"]));
				}
				/*<!--##
				}
				##-->*/
				
				this.DataSetName = ds.DataSetName;
				this.Prefix = ds.Prefix;
				this.Namespace = ds.Namespace;
				this.Locale = ds.Locale;
				this.CaseSensitive = ds.CaseSensitive;
				this.EnforceConstraints = ds.EnforceConstraints;
				this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
			}
			
			this.GetSerializationData(info, context);
		}

		
   		
		//**Methods
		
        //**Overridden Members

		//**Properties
		#region DataTables
		/*<!--##
		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];
			<%@EntityIncludes%>
		##-->*/
		public <!--##=className##-->DataTable Table_<!--##=className##-->
		{
			get
			{
				return (<!--##=className##-->DataTable)this.Tables["<!--##=entityName##-->"];
			}
		}
		/*<!--##
		}
		##-->*/
		#endregion
		
					
		#region Relational Properties

		#region DataRelations
		/*<!--##
		foreach(string key in RepositoryManager.Instance.Entities.Keys)
		{ 
			Entity entity = RepositoryManager.Instance.Entities[key];
			foreach(string relKey in  entity.Parents.Keys)
			{   
				Entity.Relation relation = entity.Parents[relKey];
				<%@RelationIncludes%>
		##-->*/
		public DataRelation Relation_<!--##=parentRelationProperty##-->
		{
			get
			{
				return this.Relations["<!--##=parentRelationName##-->"];
			}
		}
		/*<!--##
			}  
		}
		##-->*/
		#endregion

		
	
		#endregion
		
		#endregion


<!--##/session##-->
#endregion
